\chapter{Gameplay}
\label{chap:gameplay}

The program is a puzzle game, where the player's task is to foresee, and respond the actions of planner controlled agents, and act accordingly to lead them without their knowledge or any direct control towards a selected aim.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Running the game}

Our program requires a \emph{Java} executing environment; it can be started as a shell script. For the list of accepted parameters see subsection~\ref{sec:runningTheGame} in the use documentation (Appendix~\ref{chap:userDocGame}).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Game mechanics}

The basic situation in all game levels is that the burglar -- a computer controlled agent -- tries to steal a valuable artifact from a museum secured by an unspecified number of guards and cameras, which, if turned on, detect the burglar. The complication is that the burglar knows only some of these dangers. The levels are designed in a way that without the help of the player the burglar will surely be caught. The burglar is captured only if he gets into the same room with a patrolling guard or with an active camera. In the rest of the paper such places will be called \emph{trap rooms}. The only agents in the game are the guards and the burglar.

The human player observes the game world from a bird's eye view. His role is to change small details of the environment and prevent the burglar getting caught on his mission. The player wins when the computer controlled burglar manages to run away with the artifact, he looses if the protagonist gets caught.

\subsection{Game turns and environment}
\label{subs:gameTurn}

We define \emph{game turn} as the shortest perceivable time quantum in our world. In a single game turn each acting agent executes a single atomic action (for a list of these see section~\ref{sec:effectors}).

The \emph{game area} is the place where agents are acting out their plans in interaction with the objects of the environment. The layout is split to rooms that are connected to each other through doors. The rooms can be further divided into rectangular tiles, which we will call \emph{game positions}. Each game object and agent is situated on one of these positions. A single tile may contain an operable object, or a walkable one (for example a floor). On walkable objects additional agents may stand, and in case they are immediate neighbors characters may movement between them. Each such step requires a single game turn.

The objects we may find in the rooms are cameras that catch intruders; containers that can hold keys; an artifact, that is the target for the burglar; vending machines, that distract the agents for a while; and finally doors between rooms. If a burglar or a guard has a proper key, he can lock a door or a container to prevent their usage by other agents. The player has no such limitation on any object; however, each interaction costs him a price in penalty points which he/she should keep minimal (see Context menu and Player penalties subsections below).


\subsection{Victory condition}

Winning a level we define as enabling the burglar to complete its goal. In other words, a level is won, when the burglar successfully returns to the door of its starting room, with the desired artifact in his possession.

\subsection{Losing a level}

The burglar is caught if he gets into the same room with an active camera or a patrolling guard.

Losing a level can either happen if the burglar is actually caught; or if he runs out of ideas and gives up its attempts to complete the theft. Note that there is no necessary connection between the burglar knowing of no available path towards its desired treasure, and the actual nonexistence of such action sequence. Part of the player's task is to manipulate the character into discovering alternative solutions.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Intent visualization}

While looking at the game area the player always sees the true state of the world. We use \emph{color filters} and \emph{plan visualization} drawn over the world layout to let the player see an agent's beliefs. 

\begin{figure}[H]
%\begin{wrapfigure}{r}{0.5\textwidth}
  \centering
  \subfloat[]{\label{fig:knownVender}\includegraphics[width=16mm]{../img/screenshots/known_vender.eps}}
  \qquad %add desired spacing between images, e. g. ~, \quad, \qquad etc. (or a blank line to force the subfig onto a new line)
  \subfloat[]{\label{fig:mistakenVender}\includegraphics[width=16mm]{../img/screenshots/mistaken_vender.eps}}
  \qquad %add desired spacing between images, e. g. ~, \quad, \qquad etc. (or a blank line to force the subfig onto a new line)
  \subfloat[]{\label{fig:unknownVender}\includegraphics[width=16mm]{../img/screenshots/unknown_vender.eps}}
  \caption{a) a known vending machine, b) an active vending machine with mistaken details, c) an unknown active vending machine}
  \label{fig:filters}
\end{figure}
%\end{wrapfigure}

\emph{Color filters}: We have three different shades to represent the knowledge of the selected agent. To represent the agent's beliefs about a given object we use these filter on it. Objects that match in all their relevant details with the beliefs of the agent are drawn without discoloring (figure~\ref{fig:knownVender}). Objects known by the agent, but differing in some details from the agent's remembered image we draw in a slight gray tone (figure~\ref{fig:mistakenVender}). Finally objects that's existence is not known by the agent are drawn with a dark gray shade (figure~\ref{fig:unknownVender}). Objects that only exist in the mind of an agent, but not in the game world are not expected to occur in the game; if they did they would be invisible to the player.

\begin{figure}[H]
%\begin{wrapfigure}{r}{0.5\textwidth}
	\begin{center}
	\includegraphics[width=40mm]{../img/screenshots/intent_line.eps}
	\end{center}	
	\caption{Burglar's intent to approach a vending machine}
	\label{fig:intentLine}
\end{figure}
%\end{wrapfigure}

\emph{Plan visualization}: A series of black arrows (figure~\ref{fig:intentLine}) represent the planned movement actions of the agent, other intents (e.g. opening or closing something) are marked with the respective word near the object. The length of the visualized plan can be increased, or decreased by the player.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Player penalties}

Each of the user actions described in sections~\ref{sec:buttonsAndShortcuts} and \ref{sec:contextMenu} which affects a game object (e.g. activating/deactivating an object), and not the gameplay itself (e.g. changing game speed) has a penalty value. These penalties are displayed next to the action's name in parentheses. After winning or losing a level they are summed up to help differentiating between alternative solutions. We consider a victory to be better than another one, if it contains less,or more subtle actions. This is reflected in smaller penalty values.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Tutorial}

We made five introductory levels that show the main aspects and mechanisms of the game. These levels can be found in the program's default map directory named as ``tutorial\_01'',\ldots ``tutorial\_05''.

\begin{enumerate}
  \item {\bf Opening doors} -- It teaches the players how to manipulate with the game environment. Solving the level requires unlocking of at least two doors. It also demonstrates the importance of agent beliefs; if the agent does not see the newly opened door, it will not use the new path.
  \item {\bf Avoiding locations} -- On this level the players are introduced to the concept of disabling cameras where they are unavoidable and locking doors to change the burglar's path where cameras can't be avoided. It also shows the importance of different object shadings, and hints the player how to increase the visible plan distance.
  \item {\bf Avoiding moving guards} -- On this level the players learns how to switch between the plans of multiple agents. They must plan ahead and anticipate the agents' future movements in order to let the burglar slip through unnoticed. We introduce the vending machines.
  \item {\bf A guard needs some sleep} -- This level brings together both cameras and patrolling guards. The players see how a guard can be dazed and that the burglar is able to slip through camera protected rooms in a guard uniform.
  \item {\bf Hidden keys} -- The last tutorial level illustrates the use of keys, and how agents can open doors for themselves, if the player manages to guide them to those keys. The layout is the second largest we have created so far.
\end{enumerate}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Gameplay example}

In this section we provide a step by step demonstration of the gameplay on a very simple level: \emph{``map~-~paper.xml''}. It is a one of our smallest layouts, but contains many of our gameplay objects. A stationary guard, an active camera, a locked door with the appropriate key hidden in a container, a burglar and of course a treasure to find. The trap positions are placed knowing the order of preferred paths generated by the agent, so the player has to make at least a single expensive or two more subtle changes in the environment to successfully solve the level.

\begin{wrapfigure}{r}{0.5\textwidth}
  \centering
  \subfloat[The burglar's content menu at the beginning of the level]{\label{fig:screenshot01}\includegraphics[width=70mm]{../img/screenshots/map_paper/screenshot01.eps}}
  \qquad
  \subfloat[The burglar's beliefs and plan visualised]{\label{fig:screenshot02}\includegraphics[width=70mm]{../img/screenshots/map_paper/screenshot02.eps}}
  \caption{example solution (continued on the next page)}
\end{wrapfigure}

The burglar starts out at the entrance of the building, which is also the place he needs to return at the end of the level. It is a good idea to look up every trap position, to help the player such rooms are well light, while the rest of them is dark. On figure~\ref{fig:screenshot01} we switch on intent visualization for the burglar through its content menu.

Figure~\ref{fig:screenshot02} shows the intent of the burglar as a series of black arrows and its beliefs as color filters. From this screenshot we may see, that the protagonist does not know about the guard in the left side path neither the camera in the middle one. A lighter, but still visible shade on the right side path's locked door suggests that he knows about the door's existence, but is mistaken about some details. The coloring does not give away the exact nature of the burglar's mistake, but knowing a door object's possible properties we may conclude that he either thinks it's already opened or simply just unlocked.

Looking at the intent line we may see that the agent plans to reach the container using the middle path leading him through a camera protected room.

\clearpage

\begin{wrapfigure}{r}{0.5\textwidth}
  \centering
  \subfloat[Door locked to force the burglar to an alternative path]{\label{fig:screenshot03}\includegraphics[width=70mm]{../img/screenshots/map_paper/screenshot03.eps}}
  \qquad
  \subfloat[New path selected through the guard protected room]{\label{fig:screenshot04}\includegraphics[width=70mm]{../img/screenshots/map_paper/screenshot04.eps}}
  \qquad
  \subfloat[The burglar going through the only remaining path to the treasure]{\label{fig:screenshot05}\includegraphics[width=70mm]{../img/screenshots/map_paper/screenshot05.eps}}
  \caption{example solution (continued from the previous page)}
\end{wrapfigure}

Figure~\ref{fig:screenshot03} shows the level after we have locked the first door on the middle path to prevent the burglar from entering an observed room. Note that the color of the door darkened, and the agent's predicted path did not change yet. He has to reach the door first to discover that his original plan is not executable any more. 

Figure~\ref{fig:screenshot04} shows the updated situation after the burglar reached the door locked on figure~\ref{fig:screenshot02}. Now he already knows the middle path is inaccessible, so the agent has generated an alternative solution through the left side room that unfortunately leads him to meet a guard.

Figure~\ref{fig:screenshot05} was taken several game turns after the previous one. In between we locked the door leading to the room on the left and the agent had to reconsider its actions. It choose the only remaining path leading through the rooms on the right.

\clearpage

\begin{wrapfigure}{r}{0.5\textwidth}
  \centering
  \subfloat[The burglar returning for a key]{\label{fig:screenshot06}\includegraphics[width=70mm]{../img/screenshots/map_paper/screenshot06.eps}}
  \qquad
  \subfloat[The burglar on its way back to the level entrance]{\label{fig:screenshot07}\includegraphics[width=70mm]{../img/screenshots/map_paper/screenshot07.eps}}
  \qquad
  \subfloat[The level is successfully solved]{\label{fig:screenshot08}\includegraphics[width=80mm]{../img/screenshots/map_paper/screenshot08.eps}}
  \caption{example solution (continued from previous page)}
\end{wrapfigure}

Figure~\ref{fig:screenshot06} shows the burglar as it returns for a key after it discovers that the door on the right was all along locked with the key he happens to know is in the upper right container.

Figure~\ref{fig:screenshot07} shows the burglar returning to the starting position after it has successfully picked up the treasure it was looking for.

Figure~\ref{fig:screenshot08} shows the successfully solved level with the summed up penalty points.

%\begin{wrapfigure}{r}{0.5\textwidth}
%  \centering
%  \includegraphics[width=70mm]{../img/screenshots/map_paper/screenshot01.eps}
%  \caption{The \emph{burglar's} content menu at the beginning of the level}
%  \label{fig:screenshot01}
%\end{wrapfigure}
%\begin{wrapfigure}{r}{0.5\textwidth}
%  \centering
%  \includegraphics[width=70mm]{../img/screenshots/map_paper/screenshot02.eps}
%  \caption{The \emph{burglar's} beliefs and plan visualized}
%  \label{fig:screenshot02}
%\end{wrapfigure}
%\begin{wrapfigure}{r}{0.5\textwidth}
%  \centering
%  \includegraphics[width=70mm]{../img/screenshots/map_paper/screenshot03.eps}
%  \caption{Door locked to force an alternative path}
%  \label{fig:screenshot03}
%\end{wrapfigure}
%\begin{wrapfigure}{r}{0.5\textwidth}
%  \centering
%  \includegraphics[width=70mm]{../img/screenshots/map_paper/screenshot04.eps}
%  \caption{New path selected through the \emph{guard} protected room}
%  \label{fig:screenshot04}
%\end{wrapfigure}
%\begin{wrapfigure}{r}{0.5\textwidth}
%  \centering
%  \includegraphics[width=70mm]{../img/screenshots/map_paper/screenshot05.eps}
%  \caption{The \emph{burglar} going through the only remaining path to the treasure}
%  \label{fig:screenshot05}
%\end{wrapfigure}
%\begin{wrapfigure}{r}{0.5\textwidth}
%  \centering
%  \includegraphics[width=70mm]{../img/screenshots/map_paper/screenshot06.eps}
%  \caption{The \emph{burglar} returning for a key}
%  \label{fig:screenshot06}
%\end{wrapfigure}
%\begin{wrapfigure}{r}{0.5\textwidth}
%  \centering
%  \includegraphics[width=70mm]{../img/screenshots/map_paper/screenshot07.eps}
%  \caption{The \emph{burglar} on its way back to the level entrance}
%  \label{fig:screenshot07}
%\end{wrapfigure}
%\begin{wrapfigure}{r}{0.5\textwidth}
%  \centering
%  \includegraphics[width=70mm]{../img/screenshots/map_paper/screenshot08.eps}
%  \caption{The level successfully solved}
%  \label{fig:screenshot08}
%\end{wrapfigure}

